<?php require VIEWPATH. ADMIN_DIR. DIRECTORY_SEPARATOR. 'header.php'?>
<style type="text/css">
	
</style>
<div class="page-header">
	<h1>网址栏目管理</h1>
</div>

<div class="col-xs-12">
	<a href="<?=admin_url('cms/category_edit')?>" class="btn btn-info show-modal">
		<i class="ace-icon fa fa-plus"></i> 添加网址栏目
	</a>
	<table id="dynamic-table" class="table table-striped table-bordered table-hover" style="margin-top:10px">
		<thead>
			<tr>
				<th>栏目名称</th>
				<th>栏目类型</th>
				<th>首页推荐</th>
				<th>栏目排序</th>
				<th>创建时间</th>
				<th>操作</th>
			</tr>
		</thead>
		<tbody>
			<?php foreach($categoryList as $category): ?>
				<tr>
					<td><?=$category['parent_id'] ? '&nbsp;∟ ' : ''?><?=$category['category_name']?></td>
					<td><?=$category['category_type'] == CMS_CATEGORY_NORMAL ? '<span class="label label-info mr10">普通栏目</span>' : '<span class="label label-purple mr10">文章栏目</span>'?></td>
					<td><?=$category['category_recommend'] ? '<span class="label label-purple mr10">推荐</span>' : ''?></td>
					<td><?=$category['category_sort']?></td>
					<td><?=$category['createtime']?></td>
					<td>
						<a href="<?=admin_url('cms/category_edit')?>/<?=$category['id']?>"><i class="fa fa-edit"></i> 修改</a>
						<a href="javascript:;" class="ml20 text-danger delete-category" data-id="<?=$category['id']?>"><i class="fa fa-times"></i> 删除</a>
					</td>
				</tr>
			<?php endforeach; ?>
		</tbody>
	</table>
</div>

<?php require VIEWPATH. ADMIN_DIR. DIRECTORY_SEPARATOR. 'footer.php'?>
<script src="http://channel.sinaapp.com/api.js"></script>
<script type="text/javascript">
	$(function(){
		var form = $("#category-form");

		// 删除栏目
		$("body").on("click", ".delete-category", function(e){
			var id = $(this).data("id");
			layer.confirm('该操作将会删除栏目和所有下级栏目，是否继续？', function(){
				// 提交数据
				var postUrl = "<?=admin_url('cms/delete_category_action')?>";
				var postData = {"id": id};
				ajax_post(postUrl, postData, function(res){
					window.location.reload();
				})
			});
		})
	})
</script>